package cn.qn.utils;

import java.util.Date;
import java.util.Random;

/**
 * @Auther: Bryant
 * @Date: 2018/6/1
 * @Description: 流水号
 */
public class SerialNoUtils {


    /**
     * 生成注册用户编号
     * @return
     */
    public static String createUserId(){
        StringBuilder random=new StringBuilder();
        String timestamp=DateUtils.parseDateToStr(new Date(),DateUtils.DATE_FORMAT_YYMMDD);
        random.append(timestamp).append((int)((Math.random()*9+1)*1000));
        return random.toString();
    }

    /**
     * 生成注册用户编号
     * @return
     */
    public static String createArticleId(){
        StringBuilder random=new StringBuilder();
        String timestamp=DateUtils.parseDateToStr(new Date(),DateUtils.DATE_TIME_FORMAT_YYYYMMDDHHMISS);
        random.append(timestamp).append((int)((Math.random()*9+1)*1000));
        return random.toString();
    }

    public static String randomStrNo(int size){
        if(size<0){
            return "";
        }
        Random random = new Random();
        String result="";
        for (int i=0;i<size;i++)
        {
            result+=random.nextInt(10);
        }
        return result;
    }

}
